
<?php
function V_AlbumSanphamList(&$arrayData,$arrayDataCat)
{
	$ulr = "?".MODUL."=album_sanpham&".ACTION."=";//htmlspecialchars($_SERVER['QUERY_STRING']);
	$sanpham_id = CM_getParameter("sanpham_id");
	global $db;
	//phan trang
    	$totalRows = 0;
		$paging="";
		$totalRows=count($arrayData);
		$maxRows = MAXROW;
		$maxPages =MAXPAGES;
		if($totalRows%$maxRows==0)
			$totalPages = (int)($totalRows/$maxRows);
		else
			$totalPages = (int)($totalRows/$maxRows+1);
		$curPage =CM_getParameter("curPg");
		if($curPage=="")
			$curPage =1;
		else
			$curRow = ($curPage-1)*$maxRows+1;
		$paging ="Trang thứ :&nbsp;<font color=red>".$curPage."</font>&nbsp;&nbsp;&nbsp;"."Tổng số trang :&nbsp;<FONT color=red>".$totalPages."</FONT><br> ";
		if($totalRows>$maxRows)
		{
			$start=1;
			$end=1;
			$paging1 ="";
			for($i=1;$i<=$totalPages;$i++)
			{
				if(($i>((int)(($curPage-1)/$maxPages))* $maxPages) && ($i<=((int)(($curPage-1)/$maxPages+1))* $maxPages))
				{
					if($start==1) $start=$i;
						if($i==$curPage)
							$paging1 .=  $i."&nbsp;&nbsp;";
						else
							$paging1 .= "<a href='javascript:GotoPage(".$i.")'>".$i."</a>&nbsp;&nbsp;";
					$end=$i;
				}
			}
			$paging.= "Chọn trang :&nbsp;&nbsp;" ;
			if($curPage>$maxPages)
				$paging .="<a href='javascript:GotoPage(".($start-1).")'>Trở về</a>&nbsp;&nbsp;";
			$paging.=$paging1;
			if(((($curPage-1)/$maxPages+1)*$maxPages) < $totalPages)
				$paging .= "<a href='javascript:GotoPage(".($end+1).")'>Tiếp</a>&nbsp;&nbsp;";
		}
	
		
?>
<script>
function GotoPage(iPage){
	document.frm.action =document.frm.action  + "&curPg="+iPage;
	document.frm.submit()  ;
}
</script>
<?= CM_showError() ?>

   <font color="#FF0000" size="4">Danh sách album sản phẩm  -> <?=$arrayDataCat[0]['ten_sp']?>:</font>
   <a href="?modul=album_sanpham&action=Add&sanpham_id=<?=$sanpham_id ?>" class="thanh_link1"><strong>Thêm mới</strong></a>
   <hr width="60%" size="1" align="left">
   <form action="<?=$ulr?>List" name="frm" method="post" enctype="multipart/form-data">
   <TABLE width="99%" border="1" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bordercolordark="white">
   <TBODY>
	  <TR align="center" bgcolor="#FFE59F">
	  	<TD width="27" height="17" align="center" valign="middle" id=th1><strong><font size="2">STT</font></strong></TD>
		<TD width="24" height="17" align="center" valign="middle" id=th1><strong><font size="2">Sửa</font></strong></TD>
		<TD width="27" height="17" align="center" valign="middle" id=th1><strong><font size="2">Xóa</font></strong></TD>
		<TD width="699" align="left" valign="middle" id=th4><strong><font size="2">Tên ảnh</font></strong></TD>
		<!-- <TD width="104" align="center" valign="middle" id=th4><strong><font size="2">Hiển thị</font></strong></TD> -->
		<TD width="138" align="center" valign="middle" id=th4><strong><font size="2">Ngày cập nhật</font></strong></TD>
		
	  </TR>
<?
	if(!empty($arrayData))
	{
		$stt=0;
		$i=0;
		$low=$curRow;
		$curRow=1;
		foreach($arrayData as $row)
		{
			$stt+=1;
			/*$str_hienthi0 = "";
			if($row["hien_thi"]==1)
			{
				$str_hienthi0 = 'Có';
			}
			else
			{
				$str_hienthi0 = 'Không';
			}*/
			if(($curRow <= $totalRows) && ($curRow <= $curPage*$maxRows))
			{
				$curRow++;
				if($curRow>$low){
					$i+1;
?>
		<TR>
			<TD height="22" align=center valign="middle" class=bk12-140 bgcolor="#FFE59F"><strong>
			<font size="2"><?=$stt?></font>
			</strong></TD>
			<TD height="22" align=center valign="middle" class=bk12-140 bgcolor="#FFE59F">
			<A  href="<?=$ulr."Edit"?>&id=<? echo $row['id'];?>&sanpham_id=<?=$row['id_sanpham']?>">
			<IMG  title=Change height=16 alt=Change hspace=2   src="../images/Edit.gif" width=16 border=0></A>
			</TD>
			<TD class=bk12-140 bgcolor="#FFE59F" align="center">
			<a  onClick="return confirmDelete();"   href="<?=$ulr."Delete"?>&sanpham_id=<?=$row['id_sanpham']?>&id=<? echo $row['id']; ?>">
			<img title=Drop height=16 alt=Drop hspace=2 src="../images/Delete.gif" width=16 border=0></a>
			</TD>
			<TD align="left" valign="middle"  class=bk12-140>
			<font size="2"><? echo $row['tieu_de_anh']; ?></font>
			</TD>
			<!-- <TD width="104" align="center" valign="middle"  class=bk12-140>
			<a href="<?=$ulr."Edit_ht"?>&id=<? echo  $row['id']; ?>&hien_thi=<?=$row['hien_thi']; ?>&sanpham_id=<?=$row['id_sanpham']?>" class="thanh_link">
			<font size="2"><?=$str_hienthi0?></font></a></TD> -->
			<TD  valign="middle"  class=bk12-140> <div align="right"><font size="2"><? echo $row['ngay_tao']; ?></font></div></TD>
			
		</TR>
<?
				}
			}
		}//end foreach
	}else{
?>		<TR>
			<TD colspan="6" align="center">
				<FONT size="2">Không có ảnh nào.</FONT>
			</TD>
		</TR>
<?
	}
?>
   </TBODY>
   </TABLE>
   
   <table border="0" width="99%">
	<!--DWLayoutTable-->
	
	<tr>
		<td width="363" rowspan="2" align=left>
		  <div align="left"><font face="Arial" color="#0066cc">Tổng số bản ghi <b><font color="#ff0000">
			<? echo($totalRows);?></font></b></font></div>
			 <hr width="40%" size="1" align="left">		  
		</td>
		<td width="565" height="23" align=right valign="top"><?=$paging?></td>
	</tr>
	<tr>
	   <td height="15" align="right" valign="top">
		<A class="thanh_link1" href="<?=$ulr."list" ?>">[<strong>Trở về </strong>]</a>&nbsp;&nbsp;&nbsp; 
	   </td>			 
	</tr>
	</table>
	<input type=hidden name="textfield" value="<?=CM_getParameter("textfield")?>"> 
	<input type=hidden name="curPg" >
   </form>

<?php
}
?>